//
//  BaseNavigationController.m
//  CarsHome
//
//  Created by dapeng on 15/12/9.
//  Copyright © 2015年 dapeng. All rights reserved.
//

#import "BaseNavigationController.h"
#import "ConfigurationTheme.h"
@interface BaseNavigationController ()

@end

@implementation BaseNavigationController

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        
        //监听主题切换的通知
        [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(themeNotification:) name:ThemeChangeNotification object:nil];
    }
    
    return self;
}

- (void)themeNotification:(NSNotification *)notification {
    [self loadThemeImage];
}

- (void)loadThemeImage {
    
//    使用颜色设置navigationBar的背景颜色
        self.navigationBar.barTintColor = [[ConfigurationTheme shareInstance] getThemeColorWithName:@"ygColor"];
        self.navigationController.interactivePopGestureRecognizer.enabled = NO;
    [self.navigationBar setBackgroundImage:[[ConfigurationTheme shareInstance] getThemeImageName:@""] forBarMetrics:UIBarMetricsDefault];
    
    //设置导航栏字体颜色和大小
    [self.navigationBar setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys:[[ConfigurationTheme shareInstance] getThemeColorWithName:@"mrColor"],NSForegroundColorAttributeName,[UIFont fontWithName:@"Marion-Italic" size:21.0],NSFontAttributeName,nil]];
}

- (void)viewDidLoad{
    
    [super viewDidLoad];
    
    [self loadThemeImage];
}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
